<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/layui/layui.js"></script>

<button type="button" class="layui-btn" id="test1">
  <i class="layui-icon">&#xe67c;</i>上传文件
</button>

<script>
//执行一个laydate实例
laydate.render({
  elem: '#dateTime', //指定元素
        type:'month',
        done:function (value) {
            $('#dateTime').attr('value', value);
        }
});

layui.use('upload', function(){
  var upload = layui.upload;
  var uploadInst = upload.render({
        accept: 'file',
        elem: '#test1', //绑定元素
        bindAction: '.layui-layer-btn0', //指向一个按钮触发上传
        url: '{{$route}}', //上传接口
        choose:function(obj){
        },
        before:function (obj) {
            layer.load();
        }
        ,
        data:{
          import_time: $('#dateTime').val(),
          _token: '{{csrf_token()}}',
        }
        ,done: function(res){
          if(res.code == 0){
            layer.open({
                title:'提示',
                content:res.msg,
                });
          } else {
            layer.open({
                title:'提示',
                content:res.msg,
                yes:function (index) {
                    window.location.reload();
                    layer.close(index);
                }
            });
            layer.closeAll('loading');
          }
        }
        ,error: function(){
          layer.closeAll('loading');
        }
      });
});
</script>